package com.dqhl.community.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dqhl.community.R;
import com.dqhl.community.model.PayRecord;
import com.dqhl.community.util.ViewHolder;

import java.util.List;

/**
 * Created by cheng on 2016/9/2.
 * 缴费记录 adapter
 */
public class PayRecordListAdapter extends BaseAdapter {

    private Context context;
    private List<PayRecord> payRecordList;
    private LayoutInflater inflater;

    public PayRecordListAdapter(Context context, List<PayRecord> payRecordList) {
        this.context = context;
        this.payRecordList = payRecordList;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return payRecordList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = inflater.inflate(R.layout.lv_item_pay_record, viewGroup, false);
        }
        TextView tvAddress = ViewHolder.get(view, R.id.tv_address);
        TextView tvStatus = ViewHolder.get(view, R.id.tv_status);
        TextView tvOwnerName = ViewHolder.get(view, R.id.tv_owner_name);
        TextView tvPayItem = ViewHolder.get(view, R.id.tv_pay_item);
        TextView tvAmountOfMoney = ViewHolder.get(view, R.id.tv_amount_of_money); //缴费金额
        TextView tvPayMoney = ViewHolder.get(view, R.id.tv_pay_money); //实缴金额
        TextView tvDate = ViewHolder.get(view, R.id.tv_pay_date);

        PayRecord payRecord = payRecordList.get(i);

        String strAddress = payRecord.getCommunity_id() + payRecord.getBuilding_id()
                + payRecord.getUnit_id() + payRecord.getResidence_id();

        tvAddress.setText(strAddress);
        tvStatus.setText("已缴纳");
        tvOwnerName.setText(payRecord.getOwner_name());
        tvPayItem.setText(payRecord.getTemplate_id());
        tvAmountOfMoney.setText(payRecord.getTotal());
        tvPayMoney.setText(payRecord.getTotal());
        tvDate.setText(payRecord.getPay_time());

        return view;
    }
}
